/*
 * Copyright (C) ${year} Jeffrey Palm.
 *
 * This code is part of the Floto Project (http://jeffpalm.com/floto/).
 * Please consult the LICENSE included in the distribution.
 */
package com.jeffpalm.floto.isight;

import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

/**
 * Utilities for GUI stuff.
 */
public final class GuiUtil {

  private GuiUtil() {}

  /**
   * Opens and returns a frame surrounding the passed in image.
   * 
   * @param image
   *          image to show
   * @param exitOnClose
   *          whether we exit on close or not
   * @return a frame surrounding the passed in image
   */
  public static JFrame openImageFrame(BufferedImage image, boolean exitOnClose) {
    JFrame f = new JFrame();
    f.getContentPane().add(new JLabel(new ImageIcon(image)));
    if (exitOnClose) {
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    f.pack();
    f.setVisible(true);
    return f;
  }
}
